<template>
  <div>
    <a-card>
      <a-tabs v-model:activeKey="activeKey">
        <a-tab-pane key="1" tab="出货">
          <Sale />
        </a-tab-pane>
        <a-tab-pane key="2" tab="退货">
          <Refund />
        </a-tab-pane>
      </a-tabs>
    </a-card>

    <a-card class="mt-2">
      <div>
        <p class="text-lg font-bold">查询</p>
        <vxe-grid ref="xGrid" v-bind="gridOptions" v-on="gridEvent">
          <template #site="{ row }">
            {{ row.site ? row.site.title : "" }}
          </template>
          <template #department="{ row }">
            {{ row.department ? row.department.name : "" }}
          </template>
          <template #order_type="{ row }">
            {{ formatOrderType(row.order_type) }}
          </template>
          <template #action="{ row }">
            <vxe-button
              status="primary"
              content="详情"
              @click="detail(row)"
            ></vxe-button>
          </template>
        </vxe-grid>
      </div>
    </a-card>
  </div>
</template>

<script setup lang="ts">
import Sale from "./components/sale/Sale.vue";
import Refund from "./components/sale/Refund.vue";
import useRuleStore from "@/store/modules/rule";
import Api from "@/api/backend/api";
import XEUtils from "xe-utils";
import { message } from "ant-design-vue";
import { VXETable } from "vxe-table";
const activeKey = ref("1");
const router = useRouter();
const formatOrderType = (val) => {
  let result=""
  switch (val) {
    case 1:
      result = "进货";
      break;
    case 2:
      result = "进货退货";
      break;
    case 3:
      result = "发货";
      break;
    case 4:
      result = "发货退货";
      break;
  }
  return result;
};
const { gridOptions } = useMSaleOrder();
const xGrid = ref();
const gridEvent: VxeGridListeners<RowVO> = {
  proxyQuery() {
    console.log("数据代理查询事件");
    const grid = xGrid.value;
  },
  proxyDelete() {
    console.log("数据代理删除事件");
  },
  proxySave() {
    console.log("数据代理保存事件");
  },
};
const detail = (row) => {
  router.push(`/inventory/material/${row.id}/receiptitem`);
};
</script>

<style></style>
